<?php

namespace App\Admin\Extensions;

use App\Model\User;
use App\Model\UserForbidden;
use App\Model\UserFreezeLog;
use App\Model\UserProfile;
use Encore\Admin\Admin;

class UserForbiddenOp extends BaseAction
{
    protected function render()
    {
        $options = '';
        foreach (UserFreezeLog::REASON_TYPE as $k => $type) $options .= '<option value="' . $k . '">' . $type . '</option>';
        $html = '类型：<select id="forbidden_reason_type" class="form-control input-sm" style="width:200px; margin:2px 15%">' . $options . '</select><br/>理由：<input id="freeze_reason" class="form-control input-sm" style="width:200px; margin:2px 15%"></input>';
        Admin::script($this->script($this->actionUrl, $html));

        $cancelForbidBtn = $this->buildButton('ok', '取消禁言', ['id' => $this->id, 'status' => User::STATUS_OK, 'action' => 'status']);
        $defunctText = "<p class='btn btn-xs btn-success'>已失效</p>";;
        switch ($this->row->flag) {
            //禁言
            case 1:
                $str = [$cancelForbidBtn];
                break;
            default:
                $str = [$defunctText];
                break;
        }

        return '<br/><br/>' . implode('<br/><br/>', $str);
    }
}
